using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TCClientService;
using TCEntity;
using Image = TCEntity.Image;

namespace TimeCameraWinForm
{
  public partial class ShareDetailForm : Form
  {
    Image image;
    HttpClient client;
    public ShareDetailForm(Image image,HttpClient client)
    {
      InitializeComponent();
      this.image = image;
      this.client = client;
      if (this.image.ImageCategory[0] == 1) checkBox_Person.Checked = true;
      if (this.image.ImageCategory[1] == 1) checkBox_Scene.Checked = true;
      if (this.image.ImageCategory[2] == 1) checkBox_Animal.Checked = true;
      if (this.image.ImageCategory[3] == 1) checkBox_Car.Checked = true;
      if (this.image.ImageCategory[4] == 1) checkBox_Cartoon.Checked = true;
    }

    private void btn_Confirm_Click(object sender, EventArgs e)
    {
      if (checkBox_Person.Checked == true) image.ImageCategory[0] = 1;
      if (checkBox_Scene.Checked == true) image.ImageCategory[1] = 1;
      if (checkBox_Animal.Checked == true) image.ImageCategory[2] = 1;
      if (checkBox_Car.Checked == true) image.ImageCategory[3] = 1;
      if (checkBox_Cartoon.Checked == true) image.ImageCategory[4] = 1;
      _ = client.ShareAsync(image, () => { MessageBox.Show("分享成功"); }, _ => { MessageBox.Show("分享失败"); }, () => { MessageBox.Show("网络错误"); });
      this.Close();
    }
   
  }
}
